﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using ShoppingCart.Business.Concrete;
using ShoppingCart.Business.Abstract;

namespace ShoppingCart.WebUI.Controllers {

    public class NavController : Controller {
        private IProductService productService;

        public NavController() {
            productService = new ProductService();
        }

        public ViewResult Menu(string category = null) {

            ViewBag.SelectedCategory = category;

            IEnumerable<string> categories = productService.Products
                                    .Select(x => x.Category)
                                    .Distinct()
                                    .OrderBy(x => x);

            return View(categories);
        }
    }
}